package com.org.core.container;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;

public class CommonContainer {
	private static ServletContext sc;
	// 缓存数据
	public static Map<String, Object> dataMap = new HashMap<String, Object>();
	private CommonContainer(){}

	public static void saveContext(ServletContext servletContext) {
		sc = servletContext;
	}

	public static ServletContext getServletContext(){
		return sc;
	}
	
	public static void destroyContext() {
		sc = null;
	}

	public static void saveData(String key, Object data) {
		dataMap.put(key, data);
	}

	public static Object getData(String key){
		if(dataMap.containsKey(key) && dataMap.get(key) != null){
			return dataMap.get(key);
		}
		return null;
	}


	public static boolean containsKey(String key) {
		return dataMap.containsKey(key);
	}
}
